package com.ys.whiledemo;

/**
 * @author CodeYang
 * @Description 十进制整数 转 2进制
 * @Date 2020/12/7 14:38
 */
public class WhileTest03 {
    /**
     * 十进制转二进制:
     * 除N取余 到序排值
     *
     * @param args
     */
    public static void main(String[] args) {
        int num = 8;
        String str = "";

        while (num != 0) {
            // 倒叙 排序  ----0,0,0,1
            //  4 3 2 1 ====> 4+3->x+str ->34 -> x+34->234 x+234->1234
            str = num%2 +str;
            num/=2;
        }
        System.out.println(str);

      /*  double num2 = 0.25;
        String str2 = "";
        while (num2 !=0){

        }*/
    }
}
